<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="数据日期">
              <j-date placeholder="请选择数据日期" v-model="queryParam.dataDt"></j-date>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-button type="primary" icon="download" @click="handleExportXls('同业借贷发生额信息')">导出</a-button>
      <a-button type="primary" icon="download" @click="downloadXlsTemplate('JS_CD_AMT_BANK_LEND','同业借贷发生额信息')">模板导出</a-button>
      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <a-button @click="jhandleVerification('JS_CD_AMT_BANK_LEND')" type="primary" icon="check-square" >校验</a-button>
      <a-button @click="jhandleCheckResult('JS_CD_AMT_BANK_LEND')" type="primary" icon="download"  >下载校验结果</a-button>
      <a-button @click="jhandleCheckResultData('JS_CD_AMT_BANK_LEND','同业借贷发生额信息校验结果数据')" type="primary" icon="download">下载校验结果数据</a-button>
      <a-button @click="handleCommitSJ('commit,JS_CD_AMT_BANK_LEND')" type="primary" icon="check" >提交</a-button>
      <a-button @click="handleCopy('TYJDFS')" type="primary" icon="check" >复制上一期数据</a-button>
      <!-- 高级查询区域 -->
      <!-- j-super-query :fieldList="superFieldList" ref="superQueryModal" @handleSuperQuery="handleSuperQuery"></j-super-query-->
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;display:none">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="guid"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.guid)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>

      </a-table>
    </div>

    <js-cd-amt-bank-lend-modal ref="modalForm" @ok="modalFormOk"></js-cd-amt-bank-lend-modal>
    <HandelCheckModal ref="handelCheck" @ok="modalFormOk"></HandelCheckModal>
    <SjrqModal ref="SjrqModal" :handleAdd="handleAdd"></SjrqModal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import JsCdAmtBankLendModal from './modules/JsCdAmtBankLendModal'

  import HandelCheckModal from '../../checkData/HandelCheckModal'
  import SjrqModal from '../../common/sjrq/SjrqModal'
  export default {
    name: 'JsCdAmtBankLendList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {HandelCheckModal,SjrqModal,
      JsCdAmtBankLendModal
    },
    data () {
      return {
        description: '同业借贷发生额信息管理页面',
        // 表头
        columns: [
          {
            title: '选项',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'数据日期',
            align:"center",
            dataIndex: 'dataDt'
          },
          {
            title:'金融机构代码',
            align:"center",
            dataIndex: 'jrjgdm'
          },
          {
            title:'内部机构号',
            align:"center",
            dataIndex: 'nbjgh'
          },
          {
            title:'交易对手代码',
            align:"center",
            dataIndex: 'jydsdm'
          },
          {
            title:'交易对手代码类别',
            align:"center",
            dataIndex: 'jydsdmlb_dictText'
          },
          {
            title:'合同编码',
            align:"center",
            dataIndex: 'htbm'
          },
          {
            title:'交易流水号',
            align:"center",
            dataIndex: 'jylsh'
          },
          {
            title:'资产负债类型',
            align:"center",
            dataIndex: 'fzlx_dictText'
          },
          {
            title:'产品类别',
            align:"center",
            dataIndex: 'cplb_dictText'
          },
          {
            title:'合同起始日期',
            align:"center",
            dataIndex: 'htqsrq',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'合同到期日期',
            align:"center",
            dataIndex: 'htdqrq',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'合同实际终止日期',
            align:"center",
            dataIndex: 'htsjzzrq',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
            title:'币种',
            align:"center",
            dataIndex: 'bz_dictText'
          },
          {
            title:'发生金额',
            align:"center",
            dataIndex: 'fsje'
          },
          {
            title:'发生金额折人民币',
            align:"center",
            dataIndex: 'fsjezrmb'
          },
          {
            title:'利率是否固定',
            align:"center",
            dataIndex: 'llsfgd_dictText'
          },
          {
            title:'利率水平',
            align:"center",
            dataIndex: 'llsp'
          },
          {
            title:'定价基准类型',
            align:"center",
            dataIndex: 'djjzlx_dictText'
          },
          {
            title:'基准利率',
            align:"center",
            dataIndex: 'jzll'
          },
          {
            title:'计息方式',
            align:"center",
            dataIndex: 'jxfs_dictText'
          },
          {
            title:'发生/结清标识',
            align:"center",
            dataIndex: 'fsjqbz_dictText'
          },
          {
            title:'交易对手母公司代码',
            align:"center",
            dataIndex: 'jydsmgsdm'
          },
          {
            title:'交易对手母公司名称',
            align:"center",
            dataIndex: 'jydsmgsmc'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          list: "/jsCdAmtBankLend/jsCdAmtBankLend/list",
          delete: "/jsCdAmtBankLend/jsCdAmtBankLend/delete",
          deleteBatch: "/jsCdAmtBankLend/jsCdAmtBankLend/deleteBatch",
          exportXlsUrl: "/jsCdAmtBankLend/jsCdAmtBankLend/exportXls",
          importExcelUrl: "jsCdAmtBankLend/jsCdAmtBankLend/importExcel",
          dataCheckUrl: "/jsCdAmtBankLend/jsCdAmtBankLend/dataCheck",
          dataCommitUrl: "/jsCdAmtBankLend/jsCdAmtBankLend/dataCommit",
          dataVerification: '/jsCdAmtBankLend/jsCdAmtBankLend/dataVerification',
          exportCheckErrorDataXlsUrl:'/jsCdAmtBankLend/jsCdAmtBankLend/exportVerificationErrorDataXls',
          downloadXlsTemplateUrl: '/jsCdAmtBankLend/jsCdAmtBankLend/downloadXlsTemplate',
        },
        dictOptions:{},
        superFieldList:[],
      }
    },
    created() {
    this.getSuperFieldList();
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      getSuperFieldList(){
        let fieldList=[];
        fieldList.push({type:'string',value:'dataOrg',text:'数据机构'})
        fieldList.push({type:'string',value:'manageDept',text:'管理部门'})
        fieldList.push({type:'string',value:'datasource',text:'数据来源'})
        fieldList.push({type:'int',value:'dataSharps',text:'分片数'})
        fieldList.push({type:'string',value:'creater',text:'创建人'})
        fieldList.push({type:'string',value:'updater',text:'更新人'})
        fieldList.push({type:'string',value:'etlDt',text:'跑批日期'})
        fieldList.push({type:'string',value:'subjectNo',text:'科目代码'})
        fieldList.push({type:'string',value:'subjectName',text:'科目名称'})
        fieldList.push({type:'string',value:'khmc',text:'客户名称'})
        fieldList.push({type:'string',value:'khdm',text:'客户代码'})
        fieldList.push({type:'string',value:'jrjgdm',text:'金融机构代码'})
        fieldList.push({type:'string',value:'nbjgh',text:'内部机构号'})
        fieldList.push({type:'string',value:'jydsdm',text:'交易对手代码'})
        fieldList.push({type:'string',value:'jydsdmlb',text:'交易对手代码类别'})
        fieldList.push({type:'string',value:'htbm',text:'合同编码'})
        fieldList.push({type:'string',value:'jylsh',text:'交易流水号'})
        fieldList.push({type:'string',value:'fzlx',text:'资产负债类型'})
        fieldList.push({type:'string',value:'cplb',text:'产品类别'})
        fieldList.push({type:'date',value:'htqsrq',text:'合同起始日期'})
        fieldList.push({type:'date',value:'htdqrq',text:'合同到期日期'})
        fieldList.push({type:'date',value:'htsjzzrq',text:'合同实际终止日期'})
        fieldList.push({type:'string',value:'bz',text:'币种'})
        fieldList.push({type:'number',value:'fsje',text:'发生金额'})
        fieldList.push({type:'number',value:'fsjezrmb',text:'发生金额折人民币'})
        fieldList.push({type:'string',value:'llsfgd',text:'利率是否固定'})
        fieldList.push({type:'number',value:'llsp',text:'利率水平'})
        fieldList.push({type:'string',value:'djjzlx',text:'定价基准类型'})
        fieldList.push({type:'number',value:'jzll',text:'基准利率'})
        fieldList.push({type:'string',value:'jxfs',text:'计息方式'})
        fieldList.push({type:'string',value:'fsjqbz',text:'发生/结清标识'})
        fieldList.push({type:'string',value:'guid',text:'主键'})
        fieldList.push({type:'string',value:'dataDt',text:'数据日期'})
        fieldList.push({type:'string',value:'legalCode',text:'法人编号'})
        fieldList.push({type:'string',value:'jydsmgsdm',text:'交易对手母公司代码'})
        fieldList.push({type:'string',value:'jydsmgsmc',text:'交易对手母公司名称'})
        this.superFieldList = fieldList
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
